
        $(function () {
            $('#dengru').click(function () {
                $(".modal-dialog").css('display', 'block');
                $("#dier").css('display', 'none');
                // console.log({:url('index/Index/add')})
            })
        });
        $(function () {
            $('#deng').click(function () {
                $(".modal-dialog").css('display', 'block');
                $("#dier").css('display', 'none');
                // console.log({:url('index/Index/add')})
            })
        });
        $(function () {
            $("#btn2").click(function () {
                $(".modal-dialog").css('display', 'none');
                $("#dier").css('display', 'block');
            });
        });

        var head = $(".header-search").height();
        $(window).scroll(function () {
            var topScr = $(window).scrollTop();
            console.log(topScr);
            if (topScr > head) {
                $(".top").addClass("fixed");
            } else {
                $(".top").removeClass("fixed");
            }
        });
      

        //订阅频道
        $(function(){
            $('.subscribe').click(function(){
                // var $id = $(this).attr('data-index');
                $hao = $('#dengru').html();
                if ($hao !== undefined) {   
                    $('#dengru').click();
                } else {

                
                $cid = $(this).attr('data');
                $list = $(".unsubscribe"+'[data = '+$cid+']');
                // alert($cid);
                var _this = this;
                $.ajax({
                    type:'post',
                    url: '/mediaz/'+$cid,
                    dataType: 'json',   
                    success:function(data){
                        // console.log(data);
                            if ( data > 0) {
                                $($list).css("display","block");
                                $(_this).css("display","none");
                                startRequest();
                            }
                       },
                    error: function(){
                            alert(9);
                    }
                });
                }
            })
        })

        //取消订阅频道
        $(function(){
            $('.unsubscribe').click(function(){
                $cid = $(this).attr('data');
                
                $list = $(".subscribe"+'[data = '+$cid+']');
                
                var _this = this;
                // console.log($cid);
                // console.log($uid);
                $.ajax({
                    type:'get',
                    url: '/medi/'+$cid,
                    dataType: 'json',    
                    success:function(data){
                               // console.log(data);
                            if (data) {
                                $($list).css("display","block");
                                $(_this).css("display","none");
                                startRequest();

                            }
                            // alert(data);
                       },
                    error: function(){
                            alert(9);
                    }
                });
            });
        })

        //栏目头 定时器  
        function startRequest() 
        { 
             $.ajax({
                    type:'get',
                    url: '/asd/',
                    dataType: 'json',  
                    success:function(data){
                           $(".navbar-header").load(location.href+" .navbar-header>*","");
                                $(".shu").load(location.href+" .shu>*","");
                       },
                    error: function(){
                            alert(9);
                    }
                }); 
        } 
       
        //关注
        $(function(){
            $('.subs').click(function(){
                // var $id = $(this).attr('data-index');
                $hao = $('#dengru').html();
                if ($hao !== undefined) {   
                    $('#dengru').click();
                } else {

                
                $buid = $(this).attr('data');
                $list = $(".unsubs"+'[data = '+$buid+']');
                // console.log($buid);
                var _this = this;
                $.ajax({
                    type:'get',
                    url: '/Articlez/'+$buid,
                    dataType: 'json',   
                    success:function(data){
                        console.log(data);
                            if ( data > 0) {
                                $($list).css("display","block");
                                $(_this).css("display","none");
                            } else {
                                alert('请不要自己关注自己');
                            }
                       },
                    error: function(){
                        alert('关注失败');

                    }
                });
                }
            })
        })

        //取消关注
        $(function(){
            $('.unsubs').click(function(){
                $buid = $(this).attr('data');
               
                $list = $(".subs"+'[data = '+$buid+']');
                
                var _this = this;
                // console.log($buid);
                // console.log($buid);
                $.ajax({
                    type:'get',
                    url: '/Articleq/'+$buid,
                    dataType: 'json',    
                    success:function(data){
                               console.log(data);
                 
                                $($list).css("display","block");
                                $(_this).css("display","none");

                          
                       },
                    error: function(){
                            alert(9);
                    }
                });
            });
        })
        //编辑
        $(function(){
            $('.bianji').click(function(){
                $hao = $('#dengru').html();
<<<<<<< HEAD

                if ($hao !== undefined) {
=======
<<<<<<< HEAD
<<<<<<< HEAD
                if ($hao !== undefined) {   
=======
                if ($hao !== undefined) {
>>>>>>> 5f3922fa251ab9eb7684e7ce37e67fdc9138030f
=======
                if ($hao !== undefined) {
>>>>>>> eb37ef826ab0653d162d4a05c8238d99ea85e487
>>>>>>> 2d79cfa8789da2f2a423d006d49f501a7ccfc9c7
                    $('#dengru').click();
                } else {
                $(this).css("display","none");
                $('.del').css("display","block");
                $('.hui').css("top","-40px");
                $('.wan').css("display","block");
<<<<<<< HEAD
<<<<<<< HEAD
            }
=======
                }
>>>>>>> 5f3922fa251ab9eb7684e7ce37e67fdc9138030f
=======
                }
>>>>>>> eb37ef826ab0653d162d4a05c8238d99ea85e487
            })
        })

        $(function(){
            $('.del').click(function(){
                $cid = $(this).attr('da-hd');
                event.preventDefault();
                $fa = $(this).parent();
                event.preventDefault();
                $.ajax({
                        type:'get',
                        url: '/medi/'+$cid,
                        dataType: 'json',    
                        success:function(data){
                                   // console.log(data);
                                // console.log(data);
                                $($fa).remove();
                                $(".navbar-header").load(location.href+" .navbar-header>*","");
                                event.preventDefault();
                           },
                        error: function(){
                                alert('取消失败');
                                event.preventDefault();
                        }
                    });
            })
        })

        //完成
        $(function(){
             $('.wan').click(function(){
                $('.del').css("display","none");
                $('.hui').css("top","-17px");
                $('.bianji').css("display","block");
                $(this).css("display","none");
             })
        })

     

        //不感兴趣
        $(function(){
            $('.doc-remove').click(function(){
              var $a = $(this).attr('da-id');
             
              $('#'+$a).remove();
              return false;
            })
        })
       //更多  
        //更多  
       $(function(){
<<<<<<< HEAD
                $(".dropdown-to").click(function(e){
                    $(".dropdo").show();
                    event.preventDefault();
                    e.stopPropagation();
                })
                $(".dropdo").click(function(e){
                    e.stopPropagation();
                });
                $(".dropdo").mouseover(function(){
                    $(".dropdo").show();
                })
=======
            $(".dropdown-to").click(function(e){
                $(".dropdo").show();
                event.preventDefault();
                e.stopPropagation();
            })
            $(".dropdo").click(function(e){
                e.stopPropagation();
            });
            $(".dropdo").mouseover(function(){
                $(".dropdo").show();
            })
           $(".dropdo").mouseout(function(){
               $(".dropdo").hide();
           })
            var node =$('.wan')
            if(!node.is(':hidden')){　　//如果node是隐藏的则显示node元素，否则隐藏
>>>>>>> 5f3922fa251ab9eb7684e7ce37e67fdc9138030f
                $(".dropdo").mouseout(function(){
                    $(".dropdo").hide();
                })

                var node =$('.wan').css('display')
                if(node == 'none'){　　//如果node是隐藏的则显示node元素，否则隐藏
                    $(".dropdo").mouseout(function(){
                        $(".dropdo").hide();
                    })
                } 
                $(document.body).click(function(){
                    $(".dropdo").hide();
                });
        });

        var dual = $(".dual");
        var dual_close = $("a.dual_close");
        var screen_w = screen.width;
        if(screen_w>1024){dual.show()}
        $(window).scroll(function(){
            var scrollTop = $(window).scrollTop();
            dual.stop().animate({top:scrollTop+260})});
        dual_close.click(function(){
            $(this).parent().hide();return false});

         // 验证 手机输入  
        function checkphone(){
            var tel = document.regForm.tel.value;
            var box = document.getElementById('box');
            if (tel.match(/^0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8}$/) == null) {
                box.innerHTML = '* 手机格式不正确!';
                box.style.color = '#f00';
                return false;
            } else{
                box.innerHTML = '* 验证通过!';
                box.style.color = '#0a0';
                return true;
            }
        }

        // 验证 密码输入
        function checkPass(){
            var pwd = document.regForm.pwd.value;
            var pas = document.getElementById('pas');
            if (pwd.match(/^[a-zA-Z]\w{5,17}$/) == null) {
                pas.innerHTML = '* 密码格式不合法!需要字母加数字最少6位,最多18位';
                pas.style.color = '#f00';
                return false;
            } else{
                pas.innerHTML = '* 验证通过!';
                pas.style.color = '#0a0';
                return true;
            }
        }

        // 验证 密码输入
        function checkRePass(){
            var pwd = document.regForm.pwd.value;
            var repwd = document.regForm.repwd.value;
            var repas = document.getElementById('repas');
            if (pwd !== repwd) {
                repas.innerHTML = '* 两次密码不一致!';
                repas.style.color = '#f00';
                return false;
            } else {
                repas.innerHTML = '* 验证通过!';
                repas.style.color = '#0a0';
                return true;
            }
        }

        //提交时 验证结果
        function checkForm(){
            return checkphone() && checkPass() && checkRePass();
        }



          //收藏
        $(function () {
            $('.article-like').on('click',function(){
                var id = $(this).attr('data-id');
                $.ajax({
                    type:'post',
                    url:'/personal/create/' + id,
                    dateType:'json',
                    success:function(data){
//                        console.log(data);
                        if(data.code == null){
                            if(data > 0){
                                $('.interact').empty().html('<span>已收藏</span>');
                            } else {
                                alert('收藏失败!!');
                            }
                        } else {
                            alert('请先登陆!再发表您的精彩评论~');
                        }
                    },
                    error:function(){
                        alert('请求出错!');
                    }
                });
            });
        });

        $(function () {
            //回复框
            $('.comment-reply').bind('click', function () {
                $(this).parents('li').children(".anser").toggle();
                $(this).parents('li').siblings().children(".anser").css('display','none');
            })

        });
        $(function () {
            //发表评论
            $('.adddiu').one('click',function () {
                 var content = $(this).siblings('.comment-input').val();
                 var aid = $(this).attr('data-id');
                    $.ajax({
                        type:'post',
                        url:'/personal/Discuss/create',
                        data: 'content='+content+'&aid='+aid,
                        dateType:'json',
                        success:function (data) {
//                            console.log(data);
                            if(data.code == null){
                                $('.no-comment').remove();
                                $('<li data-id='+data['did']+'><p style="display: block"><span class="comment-nickname">'+data["name"]+'</span><span >'+getLocalTime(data["time"])+'</span><span class="comment-reply float-right">回复</span></p><p>'+data["content"]+'</p></li>').prependTo('.comments-list');
                            } else {
                                alert('请先登陆!再发表您的精彩评论~');
                            }
                        },
                        error:function () {
                            alert('请求出错!!');
                        }
                    });
            });

            $('.addanser').one('click',function () {
               var did = $(this).attr('data-id');
                var contente = $(this).siblings('.comment-input').val();
                $.ajax({
                    type:'post',
                    url:'/personal/Discuss/save',
                    data: 'contente='+ contente +'&did='+did,
                    dateType:'json',
                    success:function (data) {
                            console.log(data);
                        if(data.code == null){
                        $('<p style="margin-left: 30px;"><span>'+data['name']+': </span> <span>'+data['contente']+'</span></p>').appendTo('.asctnt');
                        } else {
                            alert('请先登陆!');
                        }
                    },
                    error:function () {
                        alert('请求出错!!');
                    }
                });
            });
        });
        function getLocalTime(nS) {
            return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
        }
